%\documentclass[5p, authoryear]{elsarticle}

% A utiliser pour la soumission :
\documentclass[preprint,review,authoryear,12pt]{elsarticle}



\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern}

\usepackage{amsmath,amsfonts,amssymb}
\usepackage{url}
\usepackage{textcomp} % Symbole celcius, euro etc.
\usepackage{subfig}
\usepackage[babel=true]{csquotes}
\usepackage{array}
\usepackage{multirow}
% \usepackage{hyperref}

\graphicspath{{img/}}

\newcolumntype{C}[1]{>{\centering}m{#1}}

\journal{Computers and Electronics in Agriculture}

\usepackage{lineno}
\linenumbers

\selectlanguage{english}

\begin{document}

\begin{frontmatter}

\author[INRA]{Jean-Romain Roussel}
\ead{jromain.roussel@gmail.com}

\author[INRA,AgroParisTech]{Frédéric Mothe}
\ead{mothe@nancy.inra.fr}

\author[Loria]{Adrien Krähenbühl}
\ead{adrien.krahenbuhl@loria.fr}

\author[Loria]{Bertrand Kerautret}
\ead{bertrand.kerautret@loria.fr}

\author[Loria]{Isabelle Debled-Rennesson}
\ead{Isabelle.Debled-Rennesson@loria.fr}

\author[INRA,AgroParisTech]{Fleur Longuetaud\corref{cor}}
\ead{longueta@nancy.inra.fr}

\cortext[cor]{Corresponding author}

\address[INRA]{INRA, UMR1092 LERFoB, 54280 Champenoux, France.}
\address[AgroParisTech]{AgroParisTech, UMR1092 LERFoB, 54000 Nancy, France.}
\address[Loria]{LORIA, UMR CNRS 7503, Université de Lorraine, 54506 Vandœuvre-lès-Nancy, France.}

\title{Automatic knot segmentation in CT images of wet softwood logs using a tangential approach}

\frontmatter

\begin{abstract}
Computed Tomography (CT) is more and more used in forestry science and wood industry to explore internal tree stem structure in a non-destructive way. Automatic knot detection and segmentation in the presence of wet areas like sapwood for softwood species is a recurrent problem in the literature. This article describes an algorithm named \textit{TEKA} able to segment knots even into sapwood or in presence of wet areas by using parallel tangential slices into the log that enable to follow the knot from the stem pith to the bark.
On each tangential slice, knot pith is detected and knot diameter is estimated by analyzing gray level variations around the knot pith.
A validation was performed on five softwood species without changing the algorithm parameters in order to assess the genericity of our approach. Compared to manual diameter measurements, the \textit{TEKA} algorithm led to a RMSE of 3.28 mm and a bias of 0.67 mm, which is rather good considering the difficulty to process such images.
\end{abstract}

\begin{keyword}
Computed tomography \sep Sapwood \sep Knottiness \sep Algorithm \sep Wood quality
\end{keyword}

\end{frontmatter}

\section{Introduction}

Knots are the continuation of branches into tree stems. Knots are major defects of wood, especially considering softwood, since they influence both aesthetic and mechanical properties of wood products. In the current economic context where it becomes necessary to produce more wood while maintaining the quality, information about the internal log structure with non-destructive methods is needed (i) to produce new scientific knowledge about tree growth and knot characteristics and (ii) to optimize the sawing pattern in order to increase the added-value of final products. In this context, X-ray Computed Tomography (CT) is largely used in research institutes and is already installed in some modern sawmills.\\

Numerous works have been conducted to develop algorithms to automatically detect log defects in X-ray CT images with a special interest for knots. \citet{Fleur01} present a review of the literature about automatic knot detection algorithms. Recent works can be added to this review: \citet{Aguilera2012}, \citet{Breining01} for Norway spruce and \citet{johansson2013} for Scots pine and Norway spruce. In overall, algorithms for knot detection and segmentation are efficient on dried wood, but a recurrent problem mentioned in the literature is the presence of wet areas generally inside sapwood \citep{Fleur01}. Indeed, within wet logs, classical approaches based on gray level values are not efficient because, for many softwood species, fresh sapwood has almost the same density as knots. Until now, \citet{johansson2013} are the only ones to propose an algorithm working in heartwood and in sapwood as well.\\

\citet{Aguilera2012} is the continuation of their approach based on deformable contours \citep{Aguilera2008b, Aguilera2008a}. Although very interesting, this method is neither fully automatic nor validated.\\

\citet{Breining01} algorithm is a classical approach based on gray level thresholding. They first remove sapwood in the CT images in order to detect knots in heartwood only, based on a fixed gray level threshold corresponding to a density of 900 kg.m$^{-3}$. Morphological operations are then used to improve the knot detection. Since the knot detection does not work in sapwood, we do not go further with the description and discussion of this algorithm.\\

\citet{johansson2013} algorithm is the continuation of \citet{Grundberg01} works. The algorithm is also based on images of concentric surfaces (CS) or cylindrical shells within the logs, following approximately annual rings. The main difference is that \citet{johansson2013} have applied their algorithm on low quality images like the ones which would be obtained by a high speed industrial CT scanner. The knot detection is based on 10 CS with a minimum of five CS in heartwood. CS are thresholded in order to detect high density objects and then ellipses are fitted on these objects. Ellipses which can be matched through at minimum three consecutive heartwood CS are assumed to correspond to knots. Regression models for size and location of knots are fitted from the detections in heartwood and they are then used to generate sub-images in sapwood CS supposed to contain the knots. Computation of gray level standard deviations in rows and columns in these sub-images confirm or not the presence of a knot. If a knot is present they \enquote{try to find the position and size of it in the sub image using morphological dilation}. This last step is not detailed. Since the authors write that the detection in sapwood succeeds only for \enquote{knots that have higher density than the surrounding sapwood}, it may be supposed that knots are detected and measured by gray level thresholding, which could not work in many cases regarding our images.\\

This paper presents an algorithm - named \textit{TEKA} - designed for knot segmentation into wet logs with sapwood of density similar to knots density. We chose to focus on the segmentation aspect.
That means that we started from already defined \enquote{knot areas}, i.e. angular sectors and height intervals framing each knot.
\textit{TEKA} was then able to separate knot from sapwood or moisture area within each previously selected knot area. Indeed, in our approach, we have assumed that detection (i.e., localization of knot areas) and segmentation (i.e., segmentation of knots within each knot area) were two different steps. About the detection step, an interesting work was performed by \citet{Adrien03, Adrien01, Adrien02} with a method called z-motion based on the subtraction of consecutive CT slices in order to detect the knot displacements. The corresponding Krähenbühl's software can be downloaded at: \url{https://github.com/akrah/TKDetection}. Our segmentation algorithm \textit{TEKA} could plug-in after such a detection algorithm.\\

Starting from a knot area, \textit{TEKA} uses a new original approach by looking at the log in a tangential view rather than the classical transversal view (i.e., CT slices or cross-sections). A tangential image is parallel to the main axis of the log and tangential with regard to annuals rings. \citet{Grundberg01} followed by \citet{johansson2013} already presented a quite similar approach but based on concentric surfaces centered on the log pith (see above).
The main difference is that our segmentation method is based on knot pith detection and analysis of gray level variations around the knot pith rather than on classical image thresholding.
Furthermore, it works indifferently on heartwood and sapwood, at least for five softwood species. Validation results are provided and discussed in section \ref{discussion}.

\section{Materials and methods}

\subsection{Sampling}

We developed and validated the algorithm based on 124 knots from 16 wet logs (12 trees) of five softwood species: four Douglas-fir logs (25 knots), three silver fir logs (31 knots), three European larch logs (25 knots), three Scots pine logs (20 knots) and three Norway spruce logs (23 knots). Logs were provided by Siat Braun, the most important softwood sawmill in France.

The knots for each species have been selected manually by trying to produce a sample which included small and big knots distributed at all height positions in the logs. The range of knot maximum diameters of our sample was 5.6 mm to 42 mm with an average of 19 mm. We selected knots with one condition: they are all present in the sapwood.

\subsection{CT scanning}
The logs were analyzed using a medical CT scanner (BrightSpeed Excel by GE Healthcare). Stacks of images were obtained. Size of images was 512 $\times$ 512 pixels. Image thickness and interval between two images were 1.25 mm. The resolution of images ranged between 0.36 and 0.81 mm/pixel depending on the log diameter.

\subsection{Manual detection and measurement of knots}

For the validation of our algorithm, each knot was manually described with the \textit{Gourmands} plug-in \citep{Colin01} for ImageJ software \citep{Schneider2012}. This tool allows the user to draw two lines of markers on both sides of the knot. From these lines, the knot diameter in the direction tangential to log annual rings and knot trajectory were assessed in 11 positions by computing the distance between the lines and the coordinates of the mid-point every 10\% of the knot length from the log pith to the bark. Here-after, it will be assumed that these coordinates estimate the knot pith location. This is probably correct in the tangential direction but less in the vertical direction (i.e. along the main log axis) if the pith is not centered.

We also made a repeatability test based on 45 randomly chosen knots to evaluate the accuracy of the human measurements. The knots were measured twice by the same operator.
The root mean square deviations between both set of measurements were 2.15 mm for knot diameter, 5.12 mm for the pith vertical coordinate and 0.73 mm for the horizontal pith coordinate.

\subsection{Automatic knot segmentation algorithm}

The \textit{TEKA} algorithm, written in Java language as a plug-in for ImageJ software, works with stacks of tangential images (i.e., images sliced tangentially to annual growth rings). We have previously resliced the original stack of CT images (cross-section slices perpendicular to the main log axis) to produce stacks of tangential images of the knots from the log pith to the bark (Fig. \ref{decoupeTan}). This step was performed using an ImageJ macro taking as input a radial line passing through the knot, manually drawn by the operator. We have produced tangential images every $R$ millimeter from the log pith with $R$ being the pixel width of the original CT slices.

The \textit{TEKA} plug-in delivers knot diameter (actually, knot radius) and knot pith coordinates for each tangential image.
Segmented images of the knot are also delivered for visualizing the results.

\begin{center}
*****Figure \ref{decoupeTan} about here*****
\end{center}

\subsection{Statistical validation}

For each knot, we have compared the diameters and knot center coordinates, manually measured every 10\% of the knot length, with the corresponding automatic measurements at the same locations. In total, since the first knot diameter is null, 1240 diameters and 1364 coordinates were compared (124 knots $\times$ 10 or 11 measurements per knot).

The statistical software R \citep{R} was used for statistical validation. The statistical values that were computed are: root mean square deviation (RMSD) and error (RMSE), mean absolute error (MAE), r-square (R$^2$) and the mean bias (computed as the mean of (automatically measured values $-$ manually measured values)).

\section{Description of the segmentation algorithm}

The \textit{TEKA} algorithm can be divided into three main steps:

\begin{enumerate}
\item Knot pith detection;
\item Knot radius measurement;
\item Post-processing.
\end{enumerate}

Step 1 and 2 are processed on each tangential image (after reslicing the original CT images, see Fig. \ref{decoupeTan}) whereas step 3 concerns the whole profile.

\subsection{Step 1: Knot pith detection}

\textit{PithExtract} algorithm initially presented by \citet{Fleur02} and recently improved and validated on a big set of 100451 CT-images by \citet{Boukadida01} was used. \textit{PithExtract} is based on a Sobel edge detection, where edges correspond here to the border of the knot cross-section, and the Hough accumulation principle. The pith detection is robust even with partial information, noise or ellipticity.

%From the knot pith profile, the algorithm calculates an inclination profile of the knot. The inclination profile is the discrete derivative of the vertical pith position profile, assuming that horizontal deviations are negligible. In the following, $\alpha$ is the vertical inclination of a knot at a given location between the stem pith and the bark.

\subsection{Step 2: Knot radius measurement}

It was assumed that knots had circular shapes on cross-sections oriented perpendicularly to the knot pith profile. Actually, \citet{Merkel1967} in \citet{Fleur01} reported a 1.057 ratio between diameter measured vertically and diameter measured horizontally for Norway spruce knots. \textit{TEKA} computes the knot radius in each tangential slice in two sub-steps:

\begin{enumerate}
\item Polar elliptic transform centered on the knot pith;
\item Analysis of the gray level profile.
\end{enumerate}

\subsubsection{Sub-step 1: Polar elliptic transform centered on the knot pith}

%Since knot cross-sections in planes oriented perpendicularly to the knot pith profile are almost circular and due to the knot inclination, it results that knot intersections with tangential images have an elliptical shape. For each tangential image, an ellipticity rate $\tau$ is computed from the $\alpha$ angle.
%\[ \tau = \frac{R_2}{R_1} = \cos \alpha \]
%Where $R_1$ is the major radius and $R_2$ is the minor radius of an ellipse.

Since knot cross-sections, in planes oriented perpendicularly to the knot pith profile, are almost circular, and due to the knot inclination, it results that knot intersections with tangential images have an elliptical shape.
For each tangential image, an ellipticity rate $\tau$ is computed from the local vertical inclination angle $\alpha$. This angle $\alpha$ is the discrete derivative of the vertical pith position profile, assuming that azimuthal deviations are negligible:\\
\[ \alpha = \arctan{ \frac{\Delta z}{\Delta r}}\]
\[ \tau = \frac{R_2}{R_1} = \cos \alpha \]

Where $\Delta r$ is the horizontal distance between two successive tangential slices, $\Delta z$ is the corresponding vertical deviation of the knot pith, $R_1$ and $R_2$ are the major and minor radii of an ellipse.

Then, a polar elliptic transform centered on the automatically detected knot pith was performed. Like polar circular transform, polar elliptic transform consists in converting the image from cartesian to polar coordinates but with using parametric equations of ellipses rather than circles.
Figure \ref{polar} illustrates how that elliptic transform (Fig. \ref{polarc}) is more appropriate than circular transform (Fig. \ref{polarb}), due to the elliptical knot shape, to obtain a vertical pattern (on the left of images) corresponding to the knot.

\begin{center}
*****Figure \ref{polar} about here*****
\end{center}

The resulting image (Fig. \ref{polarc}) was then smoothed with Gaussian blur filter with $l$ pixels radius. This step allows to smooth the gray level profile (see section \ref{substep2}) for cleaning small artefacts which are sometimes present.

\subsubsection{Sub-step 2: Analysis of the gray level profile} \label{substep2}

The gray level profile corresponding to the mean values of each pixel column was computed (Fig. \ref{histogramme}). This profile $f$ has two characteristics:

\begin{enumerate}
\item A maximum value into the knot because of knot sapwood density at point $A(r_{A},y_{A}=f(r_{A}))$;
\item A negative derivative from point $A$ to the end of the knot/wood transition that occurs at point $B(r_{B}, y_{B}=f(r_{B}))$, where the derivative is 0.
\end{enumerate}

\begin{center}
*****Figure \ref{histogramme} about here*****
\end{center}

Points $A$ and $B$ are automatically detected. $r_{A}$ is an underestimation of the knot radius whereas $r_{B}$ is an overestimation. The real knot radius is estimated by equation (\ref{eqrayon}) at point $C(r_C, y_C=f(r_C))$ (Fig. \ref{histogramme}).

\begin{equation}
r_{C} = f^{-1}\left( y_B + \beta (y_{A}-y_B) \right)
\label{eqrayon}
\end{equation}

With $f^{-1}$ the $f$ reciprocal function reduced to $[r_{A}, r_{B}]$ and $\beta$ a parameter included in $[0,1]$.

The knot radius at point $C$ corresponds to the minor radius of the ellipse. Because the algorithm previously calculated the ellipticity rate $\tau$, it was possible to get the major radius as well.

Figure \ref{segmentation} illustrates two examples of knot segmentation into sapwood and into heartwood.

\begin{center}
*****Figure \ref{segmentation} about here*****
\end{center}

\subsection{Step 3: Post-processing}

The post-processing step was designed to improve the algorithm accuracy. First, the biggest errors were corrected. Then, the profile was smoothed along the knot. Last, the very end of the knot profile was corrected.

\subsubsection{Detection and correction of outliers}
\label{correction}

Some errors might appear during the knot radius computation when the pattern previously described was not present in the gray level profile. In such a case, a large overestimation or underestimation of the radius was observed. For this reason, the algorithm processed to a correction of the radii identified as outliers.\\

To identify outliers we used a non parametric regression method. We chose the LOWESS algorithm (locally weighted scatterplot smoothing) created by \citet{Cleveland1979} which is considered to be resistant to outliers. We fitted the polynomial curve on the knot radius profile (Fig. \ref{lowess}a) and we computed the residue between model and data. The outliers are the points over the limits given by $[Q_1-IQR, Q_3+IQR]$ with $Q_1$ and $Q_3$ the first and the third quartile respectively and $IQR$ the inter-quartile distance. The outliers are often given in the literature by the interval $[Q_1-1.5 \times IQR, Q_3+1.5 \times IQR]$ but in our case we think the interval is too large.\\

\begin{center}
*****Figure \ref{lowess} about here*****
\end{center}

Then, outliers were removed and the gaps were filled with an linear interpolation between the boundaries of the gaps (Fig. \ref{lowess}b).\\

We used the standard Java implementation of the LOWESS regression algorithm from the Common math 3.2 API (\url{http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/analysis/interpolation/package-summary.html}).

\subsubsection{Smoothing of the radius profile}

The radius profile was smoothed by using an approximated Gaussian blur filter with $s$ pixels radius. The knot radius at the log pith was forced to be 0. We chose the approximated Gaussian filter because it is simple and it better preserves local variations than a not weighted moving average. This step allows to have a continuous profile (Fig. \ref{lowess}c).

\subsubsection{Extrapolation of the knot radius at the bark side}

The knot segmentation was often difficult in tangential slices very close to the bark. For this reason, the radii estimated on the last $p$ percent of slices located at the bark side were deleted. The knot pattern was extrapolated with a constant radius value (last value not deleted) but still centered on the detected knot pith (Fig. \ref{lowess}c).


\section{Results} \label{accuracy}

Figures \ref{result1}, \ref{result2} and \ref{result3} show the segmentation results by \textit{TEKA} for three knots. A big one from Norway spruce (Fig. \ref{result1}), a small one from Douglas fir (Fig. \ref{result2}) and a big one from Scots pine (Fig. \ref{result3}). The three examples are visually satisfactory in comparison with what would be obtained by manual segmentation.

\begin{center}
*****Figure \ref{result1} about here*****
\end{center}

\begin{center}
*****Figure \ref{result2} about here*****
\end{center}

\begin{center}
*****Figure \ref{result3} about here*****
\end{center}

\subsection{Accuracy of the knot pith detection}

Figure \ref{moellez} shows the absolute error made on vertical and horizontal pith positioning versus the relative position along the knot. Each box is made of 124 measurements from the 124 knots.\\

\begin{center}
*****Figure \ref{moellez} about here*****
\end{center}

On vertical positioning, RMSE was 4.14 mm, mean absolute error was 1.99 mm and mean bias was +0.12 mm. R$^2$ between automatic detection and manual positioning was 0.96. For the positions 0\% and 100\%, where the errors were the highest, the RMSE were 9.47 mm and 5.10 mm, respectively. Between positions 10\% and 90\%, the RMSE ranged between 1.23 mm and 5.96 mm.

On horizontal positioning, RMSE was 1.59 mm, mean absolute error was 0.80 mm and mean bias was +0.04 mm. R$^2$ between automatic detection and manual positioning was 0.97. For the positions 0\% and 100\%, where the errors were the highest, the RMSE were 3.33 mm and 2.47 mm, respectively. Between positions 10\% and 90\%, the RMSE ranged between 0.47 mm and 2.01 mm.

\subsection{Accuracy of the diameter measurements}

Figure \ref{diameter_plot} shows the plot of diameters automatically measured by \textit{TEKA} versus corresponding manual measurements. All the 1364 measurements are represented. By definition the knot diameter at the log pith location was always 0 and thus 124 points are at (0,0) in the plot. Statistics were calculated by removing these points which would artificially improve the results.\\

\begin{center}
*****Figure \ref{diameter_plot} about here*****
\end{center}

RMSE was 3.28 mm, mean absolute error was 2.21 mm, mean bias was +0.67 mm and R$^2$ was 0.85.\\

Figure \ref{diameter_error_boxplot} presents the errors made for the diameter measurements as a function of the position along the knot. Each box is made of 124 measurements from the 124 knots. The accuracy of the diameter measurements was almost the same everywhere in the knot although errors were slightly higher close to the bark.

\begin{center}
*****Figure \ref{diameter_error_boxplot} about here*****
\end{center}

Table \ref{tabstattout} summarizes the results for the diameter measurements and pith positioning by species.\\

\begin{center}
*****Table \ref{tabstattout} about here*****
\end{center}

The accuracy of the maximum diameter measurement of each knot was also checked. From the 124 considered maximum diameters, RMSE was 3.85 mm, mean absolute error was 2.65 mm, mean bias was +0.75 mm and R$^2$ was 0.85.

\section{Discussion} \label{discussion}
\subsection{About the pith detection}

RMSE was 4.14 mm for the vertical pith positioning and 1.59 mm for horizontal pith positioning. %

The observed errors were in the same order as the root mean square difference between two repetitions of manual measurements (5.12 mm vertically, 0.73 mm horizontally). Considering moreover that the knot pith was not really measured manually but estimated through the center line of the knot, this result is really satisfactory.

The pith positioning errors were bigger vertically than horizontally. It is probably due to the uncertainty of the manual measurements which is also bigger vertically than horizontally. It can also be related to the voxel size of the initial CT images (1.25 mm vertically, 0.36 to 0.81 mm horizontally).

The pith positioning errors were bigger close to the log pith and close to the bark. Close to the log pith the knot is very small with a fuzzy shape making difficulties for the \textit{PithExtract} algorithm that was not developed for such images with very few edge pixels. Furthermore, the other knots of the same whorl might appear in the images and lead to detection errors.
At the other side, the external knot end is often perturbed by bark, resin pockets or other complications which increased the detection errors.

\subsection{About the diameter measurement}

RMSE was 3.28 mm for the diameter measurements. Like for pith location, the accuracy of diameter measurements was in the same order as the repetition of manual measurements (RMSD = 2.15 mm), which is satisfactory.

For comparison purposes, \citet{Breining01} gave a RMSE of 4 mm, a bias of 1.7 mm and a R$^2$ of 0.68 based on 119 knot measurements in heartwood only and for Norway spruce. \citet{Fleur01} provided validation results based on 365 knots from Norway spruce and silver fir detected into dried logs without any sapwood problem on the images. For the maximum diameter measurements, they obtained a RMSE of 3.4 mm, a bias of -1.8 mm and a R$^2$ of 0.87. About \citet{johansson2013} algorithm, the only one in the literature dealing with knots included into sapwood, they presented relatively high errors (RMSE for maximum diameter of 4.6 mm for pine, 5.1 for spruce) but since they have used simulated images from a high speed CT scanner, comparisons are not relevant.

\subsection{Choice of the parameters}

The \textit{TEKA} algorithm depends on several parameters. Parameters have been set empirically but a sensitivity analysis and an optimization work would be interesting to perform before a complete validation. It was interesting and satisfactory for the genericity of our approach that parameters were not dependent on the species.

\begin{itemize}
\item The $\beta$ parameter was fixed at 0.75;
\item The Gaussian blur radius $l$ for the image after polar elliptic transform was 7 pixels;
\item The percentage $p$ of the knot length for which diameters were extrapolated was 10\%;
\item The Gaussian blur radius $s$ for the knot radius profile was 22 pixels;
\item The LOWESS regression algorithm from the Common math 3.2 API takes 3 parameters named \textit{bandwidth, robustness} and \textit{accuracy}. We used respectively the values 0.33, 3 and 0 for these parameters.
\item Other parameters were the \textit{PithExtract} parameters described in \citet{Boukadida01}. We have used the same values for parameters except for wood / background threshold (i.e., parameter $B$) for which we used -300 HU rather than -700 HU.
\end{itemize}

\section{Conclusion}

A knot segmentation algorithm named \textit{TEKA} was developed based on a new tangential slices approach.

The \textit{TEKA} algorithm works indifferently for different softwood species: Douglas-fir, silver fir, European larch, Scots pine or Norway spruce. Parameters are independent of the species. The algorithm works regardless of the moisture content of wood and the knot location in heartwood or in sapwood.
Starting from parallel tangential slices following the knot radial direction, the segmentation is based on the detection of knot pith on each tangential slice and the analysis of gray level variations around the knot pith.
These characteristics make \textit{TEKA} robust enough to process a large range of configurations.

The results for knot pith detection and for knot diameter measurements can be considered as very accurate in comparison with the repeatability test of corresponding manual measurements.

A free and open source version of the \textit{TEKA} plug-in for ImageJ will be soon published online.

\section*{Acknowledgement}
We would like to thank Ets. Siat-Braun who graciously supplied the log samples and Charline Freyburger who performed scanner measurements. The UMR1092 LERFoB is supported by the French National Research Agency through the Laboratory of Excellence ARBRE (ANR-12- LABXARBRE-01).

\section*{References}

\bibliographystyle{elsarticle-harv}
\bibliography{bibliographie}

\clearpage
\begin{table*}[!h]

\footnotesize
\centering
\begin{tabular}{ l | C{1cm} C{1.8cm} C{0.5cm} | C{1cm} C{1.8cm} C{0.5cm} | C{1cm} C{1.8cm} C{0.5cm}|}

\multicolumn{1}{c}{}
& \multicolumn{3}{c}{\textbf{Knot diameter}}
& \multicolumn{3}{c}{\textbf{Vertical pith position}}
& \multicolumn{3}{c}{\textbf{Horizontal pith position}}\tabularnewline

\cline{2-10}

& RMSE (mm) & Mean bias (mm) & R$^2$ & RMSE (mm) & Mean bias (mm) & R$^2$ & RMSE (mm) & Mean bias (mm) & R$^2$ \tabularnewline

\hline
\multicolumn{1}{|l|}{Douglas-fir} & 4.17 & +0.61 & 0.80 & 2.57 & -0.28 & 0.99 & 0.93 & -0.01 & 0.99 \tabularnewline
\multicolumn{1}{|l|}{Silver fir} & 2.37 & +1.20 & 0.71 & 2.22 & +0.08 & 0.92 & 1.57 & -0.09 & 0.89 \tabularnewline
\multicolumn{1}{|l|}{European larch} & 2.15 & +0.45 & 0.92 & 6.16 & +0.81 & 0.79 & 1.43 & +0.22 & 0.96 \tabularnewline
\multicolumn{1}{|l|}{Scots pine} & 4.19 & +1.77 & 0.86 & 5.76 & -0.47 & 0.97 & 2.20 & +0.16 & 0.89 \tabularnewline
\multicolumn{1}{|l|}{Norway spruce} & 3.35 & -0.68 & 0.80 & 2.90 & +0.36 & 0.94 & 1.69 & -0.02 & 0.95 \tabularnewline
\hline
\multicolumn{1}{|l|}{All species} & 3.28 & +0.67 & 0.85 & 4.14 & +0.12 & 0.96 & 1.59 & +0.04 & 0.97 \tabularnewline
\hline

\end{tabular}
\caption{Main statistics on diameter measurements and pith positioning by species.}
\label{tabstattout}

\end{table*}

\clearpage
\listoffigures

\clearpage
\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{decoupe-tangentielle}
\caption{Illustration of the tangential reslicing method. Parallel red lines correspond to the planes used for reslicing.}
\label{decoupeTan}
\end{figure}

\begin{figure}[!h]
\centering
\subfloat[]
{
\includegraphics[height=5cm]{PIN-1-T-pith}
\label{polara}
}
\,
\subfloat[]
{
\includegraphics[height=5cm]{PIN-1-T-polar}
\label{polarb}
}
\,
\subfloat[]
{
\includegraphics[height=5cm]{PIN-1-T-polarellipse}
\label{polarc}
}
\caption{Illustration of the interest of applying a polar elliptic transform. (a) Original image (Scots pine). (b) Polar circular transform with 360 radii. (c) Polar elliptic transform with 360 radii. Red cross is the knot pith automatically detected and the center of the polar transform.}
\label{polar}
\end{figure}

\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{histogramme}
\caption{Profile of mean gray level values. X-axis corresponds to the horizontal distance from the knot pith.}
\label{histogramme}
\end{figure}

\begin{figure}[!h]
\centering

\subfloat[]
{
\includegraphics[height=5cm]{PIN-1-T-seg}
\label{segmentationa}
}
\qquad
\subfloat[]
{
\includegraphics[height=5cm]{PIN-1-T-seg-duramen}
\label{segmentationb}
}
\caption{Segmentation of the knot based on elliptical shape centered on the knot pith in two tangential images of Scots pine. (a) Knot into sapwood. (b) Knot into heartwood.}
\label{segmentation}
\end{figure}

\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{lowess}
\caption{Post-processing steps: (a) Raw data with two groups of outliers points; the red line is the LOWESS curve fitted on the data. (b) Outliers are removed and gaps are filled. (c) The profile is smoothed and the end of the profile is extrapolated (here the extrapolation is not useful since there is no problem close to the bark).}
\label{lowess}
\end{figure}

\begin{figure*}[p]
\centering
\subfloat[]
{
\includegraphics[width=2.3cm]{XY-150}
\includegraphics[width=2.3cm]{XY-90}
\includegraphics[width=2.3cm]{XY-60}
\includegraphics[width=2.3cm]{XY-30}
\includegraphics[width=2.3cm]{XY-01}
\label{result1a}
}
\qquad
\subfloat[]
{
\includegraphics[width=2.3cm]{XZ-56}
\includegraphics[width=2.3cm]{XZ-64}
\includegraphics[width=2.3cm]{XZ-78}
\includegraphics[width=2.3cm]{XZ-88}
\includegraphics[width=2.3cm]{XZ-95}
\label{result1b}
}
\caption{Automatic segmentation of a Norway spruce knot from the log pith (left) to the bark (right). (a): Tangential views. (b): Transversal views.}
\label{result1}
\end{figure*}


\begin{figure*}[p]
\centering

\subfloat[]
{
\includegraphics[height=3.5cm]{DOU-1-T-tan}
\label{result2a}
}
\qquad
\subfloat[]
{
\includegraphics[height=3.5cm]{DOU-1-T-radial}
\label{result2b}
}
\qquad
\subfloat[]
{
\includegraphics[height=3.5cm]{DOU-1-T-transv}
\label{result2c}
}
\caption{Automatic segmentation of a small knot from Douglas fir. (a) Plane AA. (b) Plane BB. (c) Plane CC.}
\label{result2}
\end{figure*}

\begin{figure*}[p]
\centering
\subfloat[]
{
\includegraphics[height=5.5cm]{PIN-1-B-33-878-tan}
\label{result3a}
}
\qquad
\subfloat[]
{
\includegraphics[height=5.5cm]{PIN-1-B-33-878-rad}
\label{result3b}
}
\qquad
\subfloat[]
{
\includegraphics[height=5.5cm]{PIN-1-B-33-878-trans}
\label{result3c}
}
\caption{Automatic segmentation of a big knot from Scots pine. (a) Plane AA. (b) Plane BB. (c) Plane CC.}
\label{result3}
\end{figure*}

\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{moelleabsdist_40mm}
\caption{Absolute error on vertical and horizontal pith positioning as a function of the relative distance along the knot (0\% corresponds to the log pith location and 100\% corresponds to the log bark location; two outliers with vertical errors of 76 and 46 mm are not visible).}
\label{moellez}
\end{figure}

\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{graph}
\caption{Comparison between automatically and manually measured diameters. Diagonal line is the $y=x$ line}
\label{diameter_plot}
\end{figure}

\begin{figure}[!h]
\centering
\includegraphics[width=9cm]{graph2}
\caption{Error on diameter measurement as a function of the relative distance along the knot (0\% corresponds to the log pith location and 100\% corresponds to the log bark location).
}
\label{diameter_error_boxplot}
\end{figure}


\end{document}